<template>
  <div class="sell-header">
      <!-- 背景 -->
      <div class="background">
          <img :src="seller.avatar" alt="" width="100%" height="100%"/>
      </div>
      <!-- 内容区 -->
      <div class="content-wrapper">
          <!-- 头像 -->
          <div class="avatar">
              <img :src="seller.avatar" alt="" width="64" height="64"/>
          </div>
          <!-- 内容 -->
          <div class="content">
              <div class="title">
                  <span class="brand"></span>
                  <span class="name">{{seller.name}}</span>
              </div>
              <div class="description">{{seller.description}}/{{seller.deliveryTime}}分钟送达</div>
              <div v-if="seller.supports" class="suport">
                  <span class="icon" :class="firstIcon"></span>
                  <span class="text">{{seller.supports[0].description}}</span>
              </div>
          </div>
          <div v-if="seller.supports" class="support-count" @click="showDetail">
              <span class="count">{{seller.supports.length}}个</span>
              <i class="icon-keyboard_arrow_right"></i>
          </div>
      </div>
      <!-- 公告区 -->
      <div class="bulletin-wrapper" @click="showDetail">
          <span class="bulletin-title"></span><span class="bulletin-text">{{seller.bulletin}}</span>
          <i class="icon-keyboard_arrow_right"></i>
      </div>
      <!-- 弹窗浮层 -->
      <transition name="fade">
        <!-- fade动画class最后会和detail同级，所以可以写在detail层级下，如果可以复用，也可以单独写 -->
        <div v-show="detailShow" class="detail">
            <!-- sticky-footer布局有多种，个人偏向喜欢flex的解决方案，这里不是，实际用到再说 -->
            <div class="detail-wrapper clerafix">
                <div class="detail-main">
                    <h1 class="name">{{seller.name}}</h1>
                    <v-star :typeSize=48 :score="seller.score" class="star-wrapper"></v-star>
                    <v-lineTitle :title='"优惠信息"'></v-lineTitle>
                    <ul v-if="seller.supports" class="supports">
                        <li class="support-item" v-for="(item, index) in seller.supports" :key="index">
                            <span class="icon" :class="iconType[item.type]"></span>
                            <span class="content">{{item.description}}</span>
                        </li>
                    </ul>
                    <v-lineTitle :title='"商家公告"'></v-lineTitle>
                    <div class="bulletin"><p class="content">{{seller.bulletin}}</p></div>
                </div>
            </div>
            <div class="detail-close">
                <i class="icon-close" @click="closeDetail"></i>
            </div>
        </div>
      </transition>
  </div>
</template>

<script type="text/ecmascript-6">
    import SellStar from '../SellStar/SellStar';
    import LineTitle from '../LineTitle/LineTitle';

    export default {
        data () {
            return {
                detailShow: false,
                iconType: { 0: 'decrease', 1: 'discount', 2: 'special', 3: 'invoice', 4: 'guarantee' }
            };
        },
        props: {
            seller: { type: Object }
        },
        computed: {
            firstIcon: function () {
                return this.iconType[this.seller.supports[0].type];
            }
        },
        methods: {
            showDetail: function () {
                this.detailShow = true;
            },
            closeDetail: function () {
                this.detailShow = false;
            }
        },
        components: {
            'v-star': SellStar,
            'v-lineTitle': LineTitle
        }
    };
</script>

<style lang="stylus" rel="stylesheet/stylus">
@import '../commonstatic/stylus/index.styl';

.sell-header
    position relative
    color: #ffffff
    background : rgba(7,17,27,0.5)
    overflow hidden // 这个是阻止模糊溢出的
    .background
        position absolute
        top 0
        left 0
        z-index -1
        width 100%
        height 100%
        filter blur(8px)
    .content-wrapper
        position: relative
        padding: 24px 12px 18px 24px
        font-size :0
        .avatar
            display: inline-block
            vertical-align :top
            img 
                border-radius:2px
        .content
            display: inline-block
            margin-left: 16px
            font-size :14px
            .title
                font-size:0
                margin: 2px 0 8px 0
                .brand
                    display : inline-block
                    vertical-align :top
                    width: 30px
                    height: 18px
                    bg-image('brand')
                    background-size :30px 18px
                    background-repeat: no-repeat
                .name
                    font-size : 16px
                    margin-left :6px
                    color: rgb(255,255,255)
                    font-font-weight : bold
                    line-height:18px
            .description
                margin-bottom :10px
                line-height :12px
                font-size:12px
            .suport
                .icon
                    display: inline-block
                    vertical-align :top
                    width :12px
                    height :12px
                    margin-right :4px
                    background-size :12px 12px
                    background-repeat:no-repeat
                    &.decrease
                        bg-image('decrease_1')
                    &.discount
                        bg-image('discount_1')
                    &.guarantee
                        bg-image('guarantee_1')
                    &.invoice
                        bg-image('invoice_1')
                    &.special
                        bg-image('special_1')
                .text
                    font-size:10px
                    color:rgb(255,255,255)
        .support-count
            position: absolute
            right:12px
            bottom:14px
            padding:0,8px
            width :60px
            height:24px
            line-height :24px
            border-radius : 14px
            background-color :rgba(0,0,0,0.2)
            text-align :center
            .count
                vertical-align :top
                font-size:10px
            .icon-keyboard_arrow_right 
                line-height :24px
                margin-left :2px
                font-size:10px
    .bulletin-wrapper
        position relative
        height :28px
        line-height :28px
        padding : 0 22px 0 12px
        white-space: nowrap
        overflow: hidden
        text-overflow : ellipsis
        background-color rgba(7,17,27,0.2)
        .bulletin-title
            display :inline-block
            vertical-align top
            margin-top 7px
            width :22px
            height :12px
            bg-image('bulletin')
            background-size :22px 12px
            background-repeat :no-repeat
        .bulletin-text
            margin 0 4px
            vertical-align top
            font-size :10px
        .icon-keyboard_arrow_right
            position absolute
            font-size 15px
            right 12px
            bottom 4px
            margin-bottom 1px
    .detail
        position fixed
        top 0
        left 0
        z-index 100
        width 100%
        height 100%
        overflow auto
        background-color rgba(7,17,27,0.9)
        opacity 1
        backdrop-filter: blur(10px)
        &.fade-enter-active, &.fade-leave-active
            transition all 0.5s
        &.fade-enter, &.fade-leave-to
            opacity 0
            // height 0
        .detail-wrapper
            min-height :100%
            width 100%
            .detail-main
                padding-top 30px
                padding-bottom 64px
                .name
                    text-align center
                    line-height 16px
                    font-size 16px
                    font-weight 700
                .star-wrapper
                    margin 16px 0 28px
                    text-align center
                .supports
                    width 80%
                    margin 0 auto
                    .support-item
                        padding 0 12px
                        margin-bottom  12px
                        font-size 0
                        &:last-child
                            margin-bottom 0
                        .icon
                            display inline-block
                            vertical-align top
                            margin-right 6px
                            width 16px
                            height 16px
                            background-size :16px 16px
                            background-repeat:no-repeat
                            &.decrease
                                bg-image('decrease_2')
                            &.discount
                                bg-image('discount_2')
                            &.guarantee
                                bg-image('guarantee_2')
                            &.invoice
                                bg-image('invoice_2')
                            &.special
                                bg-image('special_2')
                        .content
                            line-height 16px
                            font-size 12px
                            font-weight 200
                .bulletin
                    width 80%
                    margin 0 auto
                    .content
                        padding 0 12px
                        line-height 24px
                        font-size 12px
                        font-weight 200
        .detail-close
            position relative
            width 100%
            text-align center
            margin -64px auto 0 auto
            clear both
            font-size 32px
</style>